package io.renren.modules.heartself.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.heartself.entity.ShConsultOrderEntity;
import io.renren.modules.heartself.service.ShConsultOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 咨询预约表
 *
 * @author jlk
 * @email sunlightcs@gmail.com
 * @date 2021-11-19 08:54:50
 */
@RestController
@RequestMapping("heartSelf/shConsultOrder")
public class ShConsultOrderController {
    @Autowired
    private ShConsultOrderService shConsultOrderService;

    /**
     * 列表
     */
    @GetMapping("/queryConsultOrderList")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = shConsultOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/consultOrderInfo/{consultOrderId}")
    public R info(@PathVariable("consultOrderId") Long consultOrderId) {
        ShConsultOrderEntity shConsultOrder = shConsultOrderService.getById(consultOrderId);

        return R.ok().put("shConsultOrder", shConsultOrder);
    }

    /**
     * 保存
     */
    @PostMapping("/saveConsultOrder")
    public R save(@RequestBody ShConsultOrderEntity shConsultOrder) {
        shConsultOrderService.save(shConsultOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/updateConsultOrder")
    public R update(@RequestBody ShConsultOrderEntity shConsultOrder) {
        shConsultOrderService.updateById(shConsultOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/deleteConsultOrder")
    public R delete(@RequestBody Long[] consultOrderIds) {
        shConsultOrderService.removeByIds(Arrays.asList(consultOrderIds));

        return R.ok();
    }

}
